package applications.alternativa3d {
	import alternativa.engine3d.containers.ConflictContainer;
	import alternativa.engine3d.core.Camera3D;
	import alternativa.engine3d.core.View;

	import core.SkeletonTest;

	import jazztures.objects.Skeleton;
	import jazztures.plugins.alternativa3d.Skeleton3D;

	import flash.events.Event;

	[SWF(width=1000, height=800, frameRate=30, backgroundColor=0xFFFFFF)]
	public class KinectSkeletonAlternativa3D extends SkeletonTest
	{
		private var camera:Camera3D;
		protected var world:ConflictContainer;	
		
		public function KinectSkeletonAlternativa3D()
		{
			super();
		}
		
		override protected function build():void{
			camera = new Camera3D();
			camera.view = new View(stage.stageWidth, stage.stageHeight);
			camera.x = camera.view.width/2;
			camera.y = camera.view.height/2;
			camera.z = 2000;
			camera.fov = Math.PI/4;
			addChild(camera.view);
			addChild(camera.diagram);
			
			world = new ConflictContainer();
			world.addChild(camera);
			
			addEventListener(Event.ENTER_FRAME, render);
		}
		
		private function render(evt:Event):void{
			camera.render();
		}
		
		override protected function updateSkeleton(skeleton:Skeleton, skeleton3D:Object):void{
			skeleton3D.skeleton = skeleton;
			skeleton3D.update();
		}
		
		override protected function destroySkeleton(skeleton:Object):void{
			world.removeChild(skeleton as Skeleton3D);
		}
		
		override protected function createSkeleton():Object{
			var skeleton:Skeleton3D = new Skeleton3D();
			world.addChild(skeleton);
			return skeleton;
		}
	}
}